import Vue from 'vue'
import VueRouter from 'vue-router'
import MovieView from '@/views/MovieView.vue'
import CinemaView from '@/views/CinemaView.vue'
import MineView from '@/views/MineView.vue'

Vue.use(VueRouter)

const routes = [{
        path: '/',
        redirect: 'movie/now'
    },
    {
        path: '/movie',
        name: 'movie',
        component: MovieView,
        children: [{
            path: 'city', //路径
            component: () =>
                import ('@/components/City.vue') //渲染
        }, {
            path: 'now',
            component: () =>
                import ('@/components/Now.vue')
        }, {
            path: 'coming',
            component: () =>
                import ('@/components/Coming.vue')
        }, {
            path: 'search',
            component: () =>
                import ('@/components/Search.vue')
        }],
        redirect: "/movie/now"
    },
    {
        path: '/cinema',
        name: 'cinema',
        component: CinemaView
    },
    {
        path: '/mine',
        name: 'mine',
        component: MineView
    },
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router